<include file="Public/header"/>
<include file="Public/menu"/>

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            售后
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 售后</a></li>
            <li class="active">投诉</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">

        <div class="tab-content">
            <div class="tab-pane active" id="tab_0">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title"></h3>



                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>订单号</th>
                                <th>联系电话</th>
                                <th>投诉内容</th>
                                <th>会员</th>
                                <th>操作</th>
                            </tr>
                            <foreach name="complain" item="v">
                            <tr>
                                <td></td>
                                <td>{$v.order_id}</td>
                                <td><span class="label label-success">{$v.tel}</span></td>
                                <td>{$v.message|substr=0,100}</td>
                                <td>{:get_member_msg($v['member_id'])}</td>
                                <td>
                                    <a class="btn btn-sm btn-primary replay" data-id="{$v.id}">回复</a>
                                    <a class="btn btn-sm btn-primary look" data-id="{$v.id}">查看</a>
                                    <a onclick="javascript:return del();" href="{:U('/Qgs/MemberComplain/delete', ['id' => $v['id']])}" class="delete btn btn-warning btn-success grid-refreshe">删除</a>
                                </td>
                            </tr>
                            </foreach>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <!--<input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;-->
                        <a class="btn btn-sm btn-primary grid-refresh"><i class="fa fa-refresh"></i></a>
                        <ul class="pagination pagination-sm no-margin pull-right"></ul>
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>

        </div>
    </section>
</div>
<!-- 回复（Modal） -->
<div class="modal fade" id="id-replay" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel,l" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel2">
                    回复订单
                </h4>
            </div>
            <div class="modal-body">
                <label>客服名称</label>
                <input name="name" class="form-control" id="replay_name" />
                <label>回复类容</label>
                <textarea id="replay_content" class="form-control" name="" ></textarea>
                <input name="submit" class="btn btn-default" type="submit" value="提交" id="submit-id" />
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 模态框（Modal） -->
<div class="modal fade" id="id-look" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel,l" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="">
                    查看
                </h4>
            </div>
            <div class="modal-body" id="look-msg" style="height:400px;overflow:auto;">
                <div>
                    <label class="col-sm-2 control-label">客服名称</label>
                    <label>回复内容</label>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script>
    function del() {
        var msg = "您真的确定要删除吗？";
        if (confirm(msg)==true){
            return true;
        }else{
            return false;
        }
    }
    $('.replay').click(function () {
        $('#id-replay').modal('show');
        var id = $(this).attr('data-id');
        $('#submit-id').click(function () {
            var content = $('#replay_content').val();
            var name = $('#replay_name').val();
            $.ajax({
                type: "post",
                url: "{:U('MemberComplain/replay')}",
                data: {
                    'content' : content,
                    'name' : name,
                    'id' : id
                },
                success: function(msg){
                    if (msg) {
                        alert('完成');
                    }else {
                        alert('失败');
                    }
                    window.location.reload();
                }
            });
        });
    });
    $('.look').click(function () {
        $('#id-look').modal('show');
        var id = $(this).attr('data-id');
        $('.chakan').remove();
        $.ajax({
            type: "post",
            url: "{:U('MemberComplain/look')}",
            data: {
                'id' : id
            },
			dataType: 'json',
            success: function(rs){
                var html = '';
				if(rs && rs.msg){
					for(var i=0; i< rs.msg.length; i++){
						html += '<div class="chakan"><label class="col-sm-2 control-label">'+ rs.msg[i]['operation_name'] +'</label>';
						html += '<label class="col-diy-80">'+ rs.msg[i]['message'] +'</label></div>';
					}
				}                
                $('#look-msg').html(html);
            }
        });

    });
</script>
